#ifndef IMAGEVIEWER_H
#define IMAGEVIEWER_H

#include <QWidget>
#include <QScrollArea>
#include <QLabel>
#include <QHBoxLayout>
#include <QScrollBar>
#include <QWheelEvent>

/// Image viewer widget, that contains a scrollable area and a label inside it showing the image
class ImageViewer : public QWidget
{
    Q_OBJECT

    QLabel* _label;
    QHBoxLayout* _layout;
    QScrollArea* _scrollArea;
    QImage* _image;

    double _factor;

private slots:
    void ver_moved_slot(int);
    void hor_moved_slot(int);
public:
    explicit ImageViewer(QImage *img, QWidget *parent = 0);
    ~ImageViewer();
    void wheelEvent(QWheelEvent* e);
    void move_vertical_scrollbar(const int value);
    void move_horizontal_scrollbar(const int value);
    void zoom(const double f);

    void zoom_in();
    void zoom_out();
    void zoom_reset();

    void change_image(QImage *img);

signals:
    void ver_moved(int);
    void hor_moved(int);
};

#endif // IMAGEVIEWER_H
